package logano;


import loganosystem.contrato.Banco;
import loganosystem.contrato.Entidad;
import loganosystem.negocio.BancoNegocio;
import loganosystem.negocio.EntidadNegocio;
import util.Helper;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmbanco.java
 *
 * Created on 23/04/2011, 13:04:53
 */

/**
 *
 * @author loreh
 */
public class Frmbanco extends FrmBaseEdicion {

    Banco banco = new Banco();
    BancoNegocio bancoNegocio = new BancoNegocio();

    /** Creates new form frmbanco */
    public Frmbanco() {
        initComponents();       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btCancel = new javax.swing.JButton();
        tbnombre = new javax.swing.JTextField();
        tbDireccion = new javax.swing.JTextField();
        txtnombre = new javax.swing.JLabel();
        txtdireccion = new javax.swing.JLabel();
        btAceptar = new javax.swing.JButton();
        btlimpiar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(logano.LoganoApp.class).getContext().getResourceMap(Frmbanco.class);
        btCancel.setText(resourceMap.getString("btCancel.text")); // NOI18N
        btCancel.setName("btCancel"); // NOI18N
        btCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelActionPerformed(evt);
            }
        });

        tbnombre.setText(resourceMap.getString("tbnombre.text")); // NOI18N
        tbnombre.setName("tbnombre"); // NOI18N
        tbnombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbnombreKeyPressed(evt);
            }
        });

        tbDireccion.setText(resourceMap.getString("tbDireccion.text")); // NOI18N
        tbDireccion.setName("tbDireccion"); // NOI18N
        tbDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbDireccionKeyPressed(evt);
            }
        });

        txtnombre.setText(resourceMap.getString("txtnombre.text")); // NOI18N
        txtnombre.setName("txtnombre"); // NOI18N

        txtdireccion.setText(resourceMap.getString("txtdireccion.text")); // NOI18N
        txtdireccion.setName("txtdireccion"); // NOI18N

        btAceptar.setText(resourceMap.getString("btAceptar.text")); // NOI18N
        btAceptar.setName("btAceptar"); // NOI18N
        btAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAceptarActionPerformed(evt);
            }
        });

        btlimpiar.setText(resourceMap.getString("btlimpiar.text")); // NOI18N
        btlimpiar.setName("btlimpiar"); // NOI18N
        btlimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btlimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtdireccion)
                            .addComponent(txtnombre))
                        .addGap(38, 38, 38)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbnombre, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                            .addComponent(tbDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btAceptar)
                        .addGap(18, 18, 18)
                        .addComponent(btlimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btCancel)
                        .addGap(9, 9, 9)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtnombre)
                    .addComponent(tbnombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtdireccion)
                    .addComponent(tbDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btlimpiar)
                    .addComponent(btCancel)
                    .addComponent(btAceptar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAceptarActionPerformed

       super.save();
    }//GEN-LAST:event_btAceptarActionPerformed

    private void btlimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btlimpiarActionPerformed

        tbnombre.setText("");
        tbDireccion.setText("");

    }//GEN-LAST:event_btlimpiarActionPerformed

    private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed

       dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_btCancelActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        dispose();
    }//GEN-LAST:event_formWindowClosing

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        dispose();
    }//GEN-LAST:event_formWindowClosed

    private void tbnombreKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbnombreKeyPressed
         Helper.enterKeyPressed(evt, tbDireccion);
    }//GEN-LAST:event_tbnombreKeyPressed

    private void tbDireccionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbDireccionKeyPressed
         Helper.enterKeyPressed(evt, tbnombre);
    }//GEN-LAST:event_tbDireccionKeyPressed

    @Override
    protected Entidad getValues()
    {
       this.banco.setNombre(tbnombre.getText());
       this.banco.setDireccion(tbDireccion.getText());
       return this.banco;

    }

    @Override
    protected void setValues()
    {
        tbDireccion.setText(this.banco.getDireccion());
        tbnombre.setText(this.banco.getNombre());
    }

    @Override
    protected EntidadNegocio getNegocio()
    {
        return this.bancoNegocio;
    }


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Frmbanco().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAceptar;
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btlimpiar;
    private javax.swing.JTextField tbDireccion;
    private javax.swing.JTextField tbnombre;
    private javax.swing.JLabel txtdireccion;
    private javax.swing.JLabel txtnombre;
    // End of variables declaration//GEN-END:variables

}
